// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

Item {
    width: 662
    height: 257

    Image{
        anchors.fill: parent
        fillMode: Image.Center
        source: "images/ui/balance_panel.png"
    }
    Text {
        id: playerName
        text: qsTr("Player :")
        color:"white"
        font.bold: true
        font.pixelSize: 14
        font.family: "Arial"
        x: 235
        y:24
    }
    Text {
        id: playerMoney
        text: qsTr("325 $")
        color:"#b3dd95"
        font.pixelSize: 14
        font.family: "Arial"
        anchors.left: playerName.right
        anchors.leftMargin: 10
        y:24
    }
    Text {
        id: girlName
        text: qsTr("Lilya :")
        color:"white"
        font.bold: true
        font.pixelSize: 14
        font.family: "Arial"
        x: 400
        y:24
    }
    Text {
        id: girlMoney
        text: qsTr("612 $")
        color:"#b3dd95"
        font.pixelSize: 14
        font.family: "Arial"
        anchors.left: girlName.right
        anchors.leftMargin: 10
        y:24
    }

    Sprite{
        source: "images/ui/buttons/btn_drink.png"
        grid_x:2
        grid_y:1
        x:575
        y:12
        id: btn_drink
        ToolTip{
            toolTip: "hello"
            showToolTip: true
        }
    }
    Sprite{
        source: "images/ui/buttons/btn_dressdown.png"
        grid_x:2
        grid_y:1
        x:btn_drink.x+35
        y:btn_drink.y
        id: btn_dressdown
        ma.onClicked: addCard()
    }


    ListModel{
        id:cardsModel
    }
    ListModel{
        id: pCardsModel
    }
    ListModel{
        id: cCardsModel
    }

    Component{
        id:cardComponent
        Card{
            id:card
            source: model.source; mast: model.mast; value: model.value
            ListView.onAdd: {
                card.state = "visible"
            }
        }
    }
    

    ListView{
        model: cardsModel
        interactive: false
        orientation: ListView.Horizontal
        spacing: 12
        width:parent.width
        height: parent.height
        x:15
        y:60
        delegate:  cardComponent
    }

    ListView{
        interactive: false
        model: pCardsModel
        orientation: ListView.Horizontal
        spacing: 12
        width: parent.width
        height: parent.height
        x: 30
        y:110
        delegate: cardComponent
    }
    ListView{
        interactive: false
        model: cCardsModel
        orientation: ListView.Horizontal
        spacing: 12
        width: parent.width
        height: parent.height
        x:390
        y: 110
        delegate: cardComponent
    }

    Winloose{
        id:winloose_message
        x: 161
        y: 104
        visible: false
    }


    function setPlayerName(name){
        playerName.text = qsTr(name)
    }
    function setGirlName(name){
        girlName.text = qsTr(name)
    }
    function setCPUMoney(val){
        girlMoney.text = qsTr(val);
    }
    function setPlayerMoney(val){
        playerMoney.text = qsTr(val);
    }
    function showWinLoose(msg){
        winloose_message.message = msg;
        winloose_message.visible = true;
    }
    function hideWinloose(){
        winloose_message.visible = false;
    }

    function addCard(owner,mast,card){
        var card_path = "images/cards/"+mast+"_"+String(card)+".png";
        if (owner=="player") pCardsModel.append({'source':card_path,mast:mast,value:card})
        if (owner=="cpu") cCardsModel.append({'source':card_path,mast:mast,value:card})
        if (owner=="table") cardsModel.append({'source':card_path,mast:mast,value:card})
    }
}
